﻿using System.Collections.Generic;
using StockFinder.Indicators.Day.ClosePrice;
using StockFinder.Model;
using StockFinder.Model.Constants;
using StockFinder.NorgatePremiumData;
using StockFinder.Services.PriceDatabaseAnalysers;
using System.Windows.Forms;
using StockFinder.YahooFinance;

namespace Testharness
{
    public class TestCommon
    {
        public static readonly NorgatePremiumDataStockFilePathsExtractor Norgate = new NorgatePremiumDataStockFilePathsExtractor();
        public static readonly YahooFinanceCsvStockPriceHistoryExtractor YahooFinanceCsv = new YahooFinanceCsvStockPriceHistoryExtractor();
        public static readonly YahooFinanceOnlineStockPriceHistoryExtractor YahooFinanceOnline = new YahooFinanceOnlineStockPriceHistoryExtractor();

        public static readonly AllTimeHighBreakoutPriceDatabaseAnalyser AllTimeHighPriceAnalyser = new AllTimeHighBreakoutPriceDatabaseAnalyser();

        public static readonly ExponentialMovingAverageTrueRangeClosePriceDayIndicator SmoothedAverageTrueRangeClosePrice14DayIndicator = new ExponentialMovingAverageTrueRangeClosePriceDayIndicator(14, DayIndicatorNames.CLOSE_EMATR14);
        public static readonly ExponentialMovingAverageWilderRelativeStrengthIndexClosePriceDayIndicator RSI20 = new ExponentialMovingAverageWilderRelativeStrengthIndexClosePriceDayIndicator(20, DayIndicatorNames.CLOSE_RSI20);
        public static readonly ExponentialMovingAverageClosePriceDayIndicator CloseEMA10DayIndicator = new ExponentialMovingAverageClosePriceDayIndicator(10, DayIndicatorNames.CLOSE_EMA10);

        #region Indicators
        public static readonly SimpleMovingAverageClosePriceDayIndicator CloseSMA10DayIndicator = new SimpleMovingAverageClosePriceDayIndicator(10, DayIndicatorNames.CLOSE_SMA10);
        public static readonly SimpleMovingAverageClosePriceDayIndicator CloseSMA20DayIndicator = new SimpleMovingAverageClosePriceDayIndicator(20, DayIndicatorNames.CLOSE_SMA20);
        public static readonly SimpleMovingAverageClosePriceDayIndicator CloseSMA50DayIndicator = new SimpleMovingAverageClosePriceDayIndicator(50, DayIndicatorNames.CLOSE_SMA50);
        public static readonly SimpleMovingAverageClosePriceDayIndicator CloseSMA200DayIndicator = new SimpleMovingAverageClosePriceDayIndicator(200, DayIndicatorNames.CLOSE_SMA200);
        #endregion

        public const string COMMON_DIRECTORY = "../../../Common/";
        public const string COMMON_OUTPUT = COMMON_DIRECTORY + "output.csv";

            
        /// <summary>
        /// Gets a history of prices for single stock. ASPS
        /// </summary>
        /// <returns></returns>
        public static List<DailyPrice> GetSingleTestPrices()
        {
            return Norgate.GetStockPriceHistoryFromFilename("../../../Common/ASPS.csv");
        }

        /// <summary>
        /// Gets a history of prices for single stock. ASPS
        /// </summary>
        /// <returns></returns>
        public static List<DailyPrice> GetSingleTestPrices(OpenFileDialog openFileDialog)
        {
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return Norgate.GetStockPriceHistoryFromFilename(openFileDialog.FileName);
            }
            else
            {
                //use default
                return Norgate.GetStockPriceHistoryFromFilename("../../../Common/ASPS.csv");
            }
        }        
    }
}
